@extends('templates.generalstructure')

@section('contenido')
<div class="wrapper-admin">
	
	<nav class="navbar navbar-inverse">
		<div class="navbar-header">
			<a class="navbar-brand" href="{{ URL::route('admin.noticias.index') }}">Noticias</a>
		</div>
		<ul class="nav navbar-nav">
			<li><a href="{{ URL::route('admin.noticias.index') }}">Ver Todas</a></li>
			<li><a href="{{ URL::route('admin.noticias.create') }}">Crear Noticia</a>
		</ul>
	</nav>

	<!-- will be used to show any messages -->
	@if (Session::has('message'))
		<div class="alert alert-info">{{ Session::get('message') }}</div>
	@endif
	
	<table class="table table-striped table-bordered">
		<thead>
			<tr>
				<td>ID</td>
				<td>Titular</td>
				<td>Autor</td>
				<td>Fecha</td>
				<td>Acciones</td>
			</tr>
		</thead>
		<tbody>
		@foreach($noticias as $key => $value)
			<tr>
				<td>{{ $value->id }}</td>
				<td>{{ $value->titulo }}</td>
				<td>{{ $value->user->username }}</td>
				<td>{{ date("d/m/Y - H:i",strtotime($value->created_at)) }}</td>
	
				<!-- we will also add show, edit, and delete buttons -->
				<td>
	
					{{ Form::open(array('method'=>'delete','url' => URL::route('admin.noticias.destroy',$value->id), 'class' => 'pull-right')) }}
						{{ Form::submit('Borrar', array('class' => 'btn btn-warning')) }}
					{{ Form::close() }}
	
					<a class="btn btn-small btn-info" href="{{ URL::route('admin.noticias.edit', $value->id) }}">Editar</a>
	
				</td>
			</tr>
		@endforeach
		</tbody>
	</table>

</div>
@stop